home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload Trio 2
/
Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO
/
dir26
/
epi601_3.zip
/
FILES12.EXE
/
DESCRIBE.PGM
< prev
next >
Wrap
Text File
|
1994-08-22
|
4KB
|
122 lines
*****************************************************************************
* This program performs a descriptive analysis on a numeric variable
*
* Denis Coulombier 01/21/94
*****************************************************************************
SET SPLIT=OFF COLOR = 30 31 27 SPLIT=OFF DASH=OFF
CLS
* for GLOB information on the epidemic
DEFINE DECIM ###### GLOB 100
* DECIM Specifies the number of digits after the comma when displaying
* results 10=1 digit, 100=2 digits, ...
DEFINE N ###### GLOB
* Number of records with non missing values
DEFINE S1 ###### GLOB
DEFINE S2 ###### GLOB
DEFINE S3 ###### GLOB
DEFINE S4 ###### GLOB
* S1=sigma of X, S2=Sigma X², S3=Sigmma X3, S4=Sigma X^4
DEFINE M1 ###### GLOB
DEFINE M2 ###### GLOB
DEFINE M3 ###### GLOB
DEFINE M4 ###### GLOB
* Variables for holding temporay calculations
DEFINE MEDIAN ###### GLOB
DEFINE TMPMED ###### GLOB
* For median calculation
DEFINE KURTOSIS ###### GLOB
DEFINE SKEWNESS ###### GLOB
DEFINE MEAN ###### GLOB
DEFINE STD ###### GLOB
DEFINE LO ###### GLOB 999999999
DEFINE HI ###### GLOB -99999999
DEFINE VAR #####
DEFINE VARNAME __________ GLOB
* Generic variable for calculation
CLS
ECHO Select the file on which to perform the descriptive analysis
READ
CLS
IMMEDIATE VARNAME = "?Press F3 to pick a numeric variable and press <ENTER> ?"
VAR = @VARNAME
* All formulas refer to VAR now
DEFINE COUNT ## CUM
* Defined after READ since READ cancel CUM variables
IF VAR <>. THEN COUNT = COUNT + 1
* Increment COUNT for record with non missing values
SORT VAR
IMMEDIATE N = COUNT
* N= Total of records with non missing values
* N being GLOBAL, will not been changed throughout the program
* COUNT being CUM is reset to zero and incremented again before each command
IF (COUNT = (N + 1) DIV 2) THEN TMPMED = VAR
IF (COUNT = (N + 2) DIV 2) THEN TMPMED = TMPMED + VAR
* if N is odd then the ((N+1) DIV 2)th record
* is added 2 times
* if N is even then the 2 records around the
* theoretical median record are added
IF VAR <> . THEN S1 = (S1 + VAR)
IF VAR <> . THEN S2 = (S2 + VAR^2)
IF VAR <> . THEN S3 = (S3 + VAR^3)
IF VAR <> . THEN S4 = (S4 + VAR^4)
* Calculation of ΣX, ΣX², ΣX^3, and ΣX^4
IF VAR <> . AND VAR < LO THEN LO = VAR
IF VAR <> . AND VAR > HI THEN HI = VAR
* Calculate minimum and maximum range
LIST /NOECHO
* list in order to assign values defined previously
IMMEDIATE MEDIAN = TMPMED / 2
* MEDIAN was twice the real median to account for even or
* odd number of records
IMMEDIATE MEAN = (S1 / N)
IMMEDIATE MEAN = ROUND(MEAN * DECIM)/DECIM
* ROUND MEAN * DECIM, to set the number of digits after the comma
IMMEDIATE STD = ((S2 - (S1 / N * S1)) / (N - 1))^0.5
IMMEDIATE STD = ROUND(STD * DECIM)/DECIM
IMMEDIATE M3 =S3-3*(S1*S2)/N+3*(S1^3)/(N^2)
IMMEDIATE M4 =(S1^3)/(N^2)
IMMEDIATE M1 =(M3-M4)/(N-1)
IMMEDIATE M2 =(S2-S1^2/N)/(N-1)
* Temporary variables for SKEWNESS calculations
IMMEDIATE SKEWNESS =M1/M2^1.5
IMMEDIATE SKEWNESS = ROUND(SKEWNESS * DECIM)/DECIM
IMMEDIATE M3 =S4-4*S1*S3/N+6*S1^2*S2/(N*N)
IMMEDIATE M4 =3*S1^4/(N^3)
IMMEDIATE M1 =(M3-M4)/(N-1)
IMMEDIATE M2 =(S2-S1^2/N)/(N-1)
* Temporary variables for KURTOSIS calculations
IMMEDIATE KURTOSIS =M1/M2^2
IMMEDIATE KURTOSIS = ROUND(KURTOSIS * DECIM)/DECIM
SORT
ERASE DESCRIBE.TXT
ROUTE DESCRIBE.TXT
CLS
TYPE "\n\n Descriptive analysis\n\n"
TYPE " Variable: @VARNAME"
TYPE " Range: @LO to @HI"
TYPE " Median: @MEDIAN"
TYPE " Mean: @MEAN"
TYPE " Standard Deviation: @STD"
TYPE " Skewness: @SKEWNESS"
TYPE " Kurtosis: @KURTOSIS"
TYPE ""
TYPE " A skweness of zero means a symetrical distribution"
TYPE " A kurtosis of 3 means a normal distribution shape."
TYPE " A kurtosis of less than 3 means a distribution narrower"
TYPE " than a normal distribution, and a kurtosis > 3 means "
TYPE " a distribution wider than a normal distribution."
ROUTE SCREEN
QUIT
The program has to quit because global variables are permanent
A second run of the same program without quiting would lead to false results
because increments on global variables (Sigma X) would be performed twice